<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var p = new Promise(function(resolve,reject){
        // 回调函数 -> 容器 -> 用来存放异步操作 (根据异步操作的结果改变状态)

        setTimeout(()=>{
            resolve(1); // {<fulfilled>:1}
            // reject(0)   // {<rejected>:0}
            console.log(p); 
        },2000);

    })
    console.log(p); // {<pending>:undefined}

    // p.then(function(arg){
    //     console.log("fulfilled",arg);
    // },function(arg){
    //     console.log("rejected",arg);
    // })

    // p.then(null,function(arg){
    //     console.log("rejected",arg);
    // })


    // p.then().then().then().then().then(function(){}).catch()
    

    /* p.then(function(arg){
        console.log("fulfilled",arg);
        aaaa;
        return 2
    }).then(function(arg){
        console.log("fulfilled",arg);
        return 3;
    }).then(function(arg){
        console.log("fulfilled",arg);
    }).catch(function(arg){
        console.log("reject",arg);
    })*/


     p.then(function(arg){
        console.log("fulfilled",arg);
        aaaa;
        return 2
    }).then(function(arg){
        console.log("fulfilled",arg);
        return 3;
    },function(err){
        console.log("rejected:p1",err);
        return 33;
    }).then(function(arg){
        console.log("fulfilled",arg);
    }).catch(function(arg){
        console.log("rejected",arg);
    })






</script>
</html>